package com.qianke.common.util;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class TypeChangeHelper {
    public static Byte intToByte(Integer source) {
        if (source == null) {
            return null;
        }
        return source.byteValue();
    }

    public static Integer byteToInteger(Byte source) {
        if (source == null) {
            return null;
        }
        return source.intValue();
    }

    public static int getIntByInteger(Integer source) {
        if (source == null) {
            return 0;
        }
        return source.intValue();
    }

    public static String getStringByBigDeciaml(BigDecimal source) {
        if (source == null) {
            return "0";
        }
        return source.setScale(2, RoundingMode.HALF_UP) + "";
    }
}
